<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="contact.domain.DAOContact"%>
<%@page import="contact.domain.Contact"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Iterator"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" media="screen" href="style.css">
<title>Home</title>
</head>
<body>
<jsp:include page="menu.html" />
<div id="content">
<form id="home">
<%
DAOContact dao = new DAOContact();
List contacts = dao.readAll();
%>
<h1>Home</h1>
<table>
	<tr>
		<th>Firstname</th>
		<th>Lastname</th>
		<th>Email</th>
		<th></th>
	</tr>
	<%
	Iterator iter = contacts.iterator();
	while (iter.hasNext()) {
		Contact contact = (Contact) iter.next();
		out.println("<tr>"
				+"<td>" + contact.getFirstName() + "</td>"
				+"<td>" + contact.getLastName() + "</td>"
				+"<td>" + contact.getEmail() + "</td>"
				+"<td><a class='submit details' href=\"showcontact.jsp?id="+contact.getId()+"\">Details</a></td>"
				+"</tr>");
	}
	%>
</table>
<h2><%= contacts.size()%> contact(s)</h2>
</form>
</div>
</body>
</html>